//剩余参数
function buildName(firstName:string,...restname:string[]):string{
    return firstName+" "+restname.join(" ");
}
buildName("jhon","rose","marcus","jack")

//this的使用
interface Card{
    suit:string;
    card:number;
}

interface Deck{
    suits:string[];
    cards:number[];
    createCardPicker(this:Deck):()=>Card;
}

let deck:Deck={
    suits: ["hearts", "spades", "clubs", "diamonds"],
    cards: Array(52),
    createCardPicker:function(this:Deck){
        return ()=>{
            let pickedCard = Math.floor(Math.random() * 52);
            let pickedSuit = Math.floor(pickedCard / 13);
            return {suit: this.suits[pickedSuit], card: pickedCard % 13};
        }
    }
}

//重载
let suits=["hearts","spades","clubs","diamonds"]
function pickCard(x:{suit: string; card: number;}[]):number;
function pickCard(x:number):{suit:string,card:number};
function pickCard(x):any{
    if(typeof x==='object'){
        return x;
    }else{
        return "XXX"
    }
}